From 516a1a1844b202fa79e0575362faa27093f5fe04 Mon Sep 17 00:00:00 2001 From: xftroxgpx Date: Tue, 18 Jul 2017 15:05:35 +0200 Subject: [PATCH] Fixes #4293 locally tested with: cargo test legacy_ many_crate_types_old_style_lib_location --- src/cargo/util/toml/targets.rs | 16 +++------------- tests/bench.rs | 2 +- tests/build.rs | 8 ++++---- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/cargo/util/toml/targets.rs b/src/cargo/util/toml/targets.rs index 498bb6637..599913c8c 100644 --- a/src/cargo/util/toml/targets.rs +++ b/src/cargo/util/toml/targets.rs @@ -16,7 +16,6 @@ use std::collections::HashSet; use core::Target; use ops::is_bad_artifact_name; use util::errors::CargoResult; -use util::paths::without_prefix; use super::{TomlTarget, LibKind, PathValue, TomlManifest, StringOrBool, TomlLibTarget, TomlBinTarget, TomlBenchTarget, TomlExampleTarget, TomlTestTarget}; @@ -106,13 +105,10 @@ fn clean_lib(toml_lib: Option<&TomlLibTarget>, let legacy_path = package_root.join("src").join(format!("{}.rs", lib.name())); if legacy_path.exists() { { - let short_path = without_prefix(&legacy_path, package_root) - .unwrap_or(&legacy_path); - warnings.push(format!( "path `{}` was erroneously implicitly accepted for library `{}`,\n\ please rename the file to `src/lib.rs` or set lib.path in Cargo.toml", - short_path.display(), lib.name() + legacy_path.display(), lib.name() )); } legacy_path @@ -178,13 +174,10 @@ fn clean_bins(toml_bins: Option<&Vec>, let path = target_path(bin, &inferred, "bin", package_root, &mut |_| { if let Some(legacy_path) = legacy_bin_path(package_root, &bin.name(), has_lib) { { - let short_path = without_prefix(&legacy_path, package_root) - .unwrap_or(&legacy_path); - warnings.push(format!( "path `{}` was erroneously implicitly accepted for binary `{}`,\n\ please set bin.path in Cargo.toml", - short_path.display(), bin.name() + legacy_path.display(), bin.name() )); } Some(legacy_path) @@ -268,13 +261,10 @@ fn clean_benches(toml_benches: Option<&Vec>, return None; } { - let short_path = without_prefix(&legacy_path, package_root) - .unwrap_or(&legacy_path); - warnings.push(format!( "path `{}` was erroneously implicitly accepted for benchmark `{}`,\n\ please set bench.path in Cargo.toml", - short_path.display(), bench.name() + legacy_path.display(), bench.name() )); } Some(legacy_path) diff --git a/tests/bench.rs b/tests/bench.rs index 094bcb3d7..cf68a629e 100644 --- a/tests/bench.rs +++ b/tests/bench.rs @@ -1186,6 +1186,6 @@ fn legacy_bench_name() { "#); assert_that(p.cargo_process("bench"), execs().with_status(0).with_stderr_contains("\ -[WARNING] path `src[/]bench.rs` was erroneously implicitly accepted for benchmark `bench`, +[WARNING] path `[..]src[/]bench.rs` was erroneously implicitly accepted for benchmark `bench`, please set bench.path in Cargo.toml")); } diff --git a/tests/build.rs b/tests/build.rs index d56c70073..59a7e4517 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -1047,7 +1047,7 @@ fn many_crate_types_old_style_lib_location() { pub fn foo() {} "#); assert_that(p.cargo_process("build"), execs().with_status(0).with_stderr_contains("\ -[WARNING] path `src[/]foo.rs` was erroneously implicitly accepted for library `foo`, +[WARNING] path `[..]src[/]foo.rs` was erroneously implicitly accepted for library `foo`, please rename the file to `src/lib.rs` or set lib.path in Cargo.toml")); assert_that(&p.root().join("target/debug/libfoo.rlib"), existing_file()); @@ -1402,7 +1402,7 @@ fn legacy_binary_paths_warinigs() { .file("src/main.rs", "fn main() {}"); assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr_contains("\ -[WARNING] path `src[/]main.rs` was erroneously implicitly accepted for binary `bar`, +[WARNING] path `[..]src[/]main.rs` was erroneously implicitly accepted for binary `bar`, please set bin.path in Cargo.toml")); let mut p = project("world"); @@ -1419,7 +1419,7 @@ please set bin.path in Cargo.toml")); .file("src/bin/main.rs", "fn main() {}"); assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr_contains("\ -[WARNING] path `src[/]bin[/]main.rs` was erroneously implicitly accepted for binary `bar`, +[WARNING] path `[..]src[/]bin[/]main.rs` was erroneously implicitly accepted for binary `bar`, please set bin.path in Cargo.toml")); let mut p = project("world"); @@ -1435,7 +1435,7 @@ please set bin.path in Cargo.toml")); .file("src/bar.rs", "fn main() {}"); assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr_contains("\ -[WARNING] path `src[/]bar.rs` was erroneously implicitly accepted for binary `bar`, +[WARNING] path `[..]src[/]bar.rs` was erroneously implicitly accepted for binary `bar`, please set bin.path in Cargo.toml")); } -- 2.30.2